<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="949.54">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #0000ff}
p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}
p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #0024b5}
p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #3b6c19}
p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #9d281b}
span.s1 {font: 18.0px Helvetica}
span.s2 {color: #000000}
span.s3 {color: #0030f2}
span.s4 {text-decoration: underline}
span.s5 {text-decoration: underline ; color: #0030f2}
span.s6 {color: #0024b5}
span.s7 {color: #3b6c19}
span.Apple-tab-span {white-space:pre}
</style>
</head>
<body>
<p class="p1"><span class="s1"><b>PokeySquare</b></span><b><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>wrapper class for the Pokey UGen</b></p>
<p class="p2"><br></p>
<p class="p2"><br></p>
<p class="p3"><span class="s2">requires my <a href="../Bit/BitOr.html"><span class="s3">BitOr</span></a> plugin.<span class="Apple-converted-space">  </span>available at </span><span class="s4">http://www.fredrikolofsson.com/pages/code-sc.html</span></p>
<p class="p2"><br></p>
<p class="p1">simplifies the interface for the [<a href="Pokey.html"><span class="s5">Pokey</span></a>] ugen a little.<span class="Apple-converted-space">  </span>provides standard ranges with clipping for all inputs.<span class="Apple-converted-space">  </span>no need to deal with bitwise register calculations, though note that this class is a bit less cpu efficient than to use the standard Pokey.</p>
<p class="p2"><br></p>
<p class="p1"><b><span class="Apple-tab-span">	</span>*ar(freq1, tone1, vol1, freq2, tone2, vol2, freq3, tone3, vol3, freq4, tone4, vol4, ctrl)</b></p>
<p class="p1"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>freq - frequency 0-255</p>
<p class="p1"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>tone - tone control 0-7</p>
<p class="p1"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>vol - volume 0-15</p>
<p class="p1"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>ctrl - general control 0-63</p>
<p class="p4"><br></p>
<p class="p4"><br></p>
<p class="p5">s.boot;</p>
<p class="p4"><br></p>
<p class="p5">{<span class="s6">PokeySquare</span>.ar(<span class="s6">Line</span>.kr(0, 255, 5), 7, 15)}.play</p>
<p class="p5">{<span class="s6">PokeySquare</span>.ar(<span class="s6">Line</span>.kr(0, 255, 5), 6, 15)}.play</p>
<p class="p5">{<span class="s6">PokeySquare</span>.ar(<span class="s6">Line</span>.kr(0, 255, 5), 4, 15)}.play</p>
<p class="p4"><br></p>
<p class="p4"><br></p>
<p class="p5">(</p>
<p class="p6">SynthDef<span class="s2">(</span><span class="s7">\pokeySquare</span><span class="s2">, {</span>|out= 0, gate= 1, f1= 0, c1= 0, v1= 15, f2= 0, c2= 0, v2= 15, f3= 0, c3= 0, v3= 15, f4= 0, c4= 0, v4= 15, ctl= 0, amp= 1, pan= 0|</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s6">var</span> e, z;</p>
<p class="p5"><span class="Apple-tab-span">	</span>e= <span class="s6">EnvGen</span>.kr(<span class="s6">Env</span>.asr(0.01, amp, 0.05), gate, doneAction:2);</p>
<p class="p5"><span class="Apple-tab-span">	</span>z= <span class="s6">PokeySquare</span>.ar(f1, c1, v1, f2, c2, v2, f3, c3, v3, f4, c4, v4, ctl);</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s6">Out</span>.ar(out, <span class="s6">Pan2</span>.ar(z*e, pan));</p>
<p class="p5">}).add;</p>
<p class="p5">)</p>
<p class="p4"><br></p>
<p class="p5">(</p>
<p class="p6">Pbind<span class="s2">(</span></p>
<p class="p7"><span class="s2"><span class="Apple-tab-span">	</span></span>\instrument<span class="s2">, </span>\pokeySquare<span class="s2">,</span></p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s7">\dur</span>, <span class="s6">Pseq</span>([<span class="s6">Pn</span>(0.1, 10), <span class="s6">Pn</span>(0.05, 12)], <span class="s6">inf</span>),</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s7">\amp</span>, 0.8,</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s7">\ctl</span>, 0,</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s7">\f1</span>, <span class="s6">Pseq</span>([<span class="s6">Pseries</span>(0, 10, 20), <span class="s6">Pgeom</span>(200, 0.94, 20)], <span class="s6">inf</span>),</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s7">\c1</span>, <span class="s6">Pseq</span>([<span class="s6">Pn</span>(7, 66), <span class="s6">Pn</span>(6, 66), <span class="s6">Pn</span>(4, 66), <span class="s6">Pn</span>(2, 66)], <span class="s6">inf</span>),</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s7">\v1</span>, 15</p>
<p class="p5">).play</p>
<p class="p5">)</p>
<p class="p4"><br></p>
<p class="p5">(</p>
<p class="p6">Pbind<span class="s2">(</span></p>
<p class="p7"><span class="s2"><span class="Apple-tab-span">	</span></span>\instrument<span class="s2">, </span>\pokeySquare<span class="s2">,</span></p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s7">\dur</span>, <span class="s6">Pseq</span>([<span class="s6">Pn</span>(0.1, 10), <span class="s6">Pn</span>(0.05, 12)], <span class="s6">inf</span>),</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s7">\amp</span>, 0.8,</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s7">\ctl</span>, 0,</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s7">\f1</span>, <span class="s6">Pseq</span>([100, 90, 120], <span class="s6">inf</span>),</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s7">\c1</span>, <span class="s6">Pseq</span>([7, 7, 7, 7, 6, 6, 7, 7], <span class="s6">inf</span>),</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s7">\v1</span>, <span class="s6">Pseq</span>([15, 0, 0, 0, 15, 0, 15, 0], <span class="s6">inf</span>),</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s7">\f2</span>, <span class="s6">Pseq</span>([<span class="s6">Pn</span>(180, 64-8), <span class="s6">Pshuf</span>([20, 22, 26, 28], 2)], <span class="s6">inf</span>),</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s7">\c2</span>, 3,</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s7">\v2</span>, <span class="s6">Pseq</span>([10, 0, 10, 0, 10, 0, 10, 0], <span class="s6">inf</span>),</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s7">\f3</span>, 11,</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s7">\c3</span>, 6,</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s7">\v3</span>, <span class="s6">Pseq</span>([<span class="s6">Pseries</span>(0, 0.05, 128)], <span class="s6">inf</span>)*<span class="s6">Pseq</span>([0, 1, 0.1, 1], <span class="s6">inf</span>),</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s7">\f4</span>, 31,</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s7">\c4</span>, 5,</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s7">\v4</span>, <span class="s6">Pseq</span>([<span class="s6">Pn</span>(0, 64), <span class="s6">Pseq</span>([<span class="s6">Pseries</span>(0, 0.1, 128)], <span class="s6">inf</span>)*<span class="s6">Pseq</span>([1, 0.1, 1, 0], <span class="s6">inf</span>)])</p>
<p class="p5">).play</p>
<p class="p5">)</p>
<p class="p4"><br></p>
<p class="p4"><br></p>
<p class="p4"><br></p>
<p class="p8">//--or use the helper methods together with the standard Pokey to do the calculations in sclang</p>
<p class="p5">({</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s6">Pokey</span>.ar(</p>
<p class="p8"><span class="s2"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></span><span class="s6">PokeySquare</span><span class="s2">.audf(100),<span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></span>//convert freq to an audf</p>
<p class="p8"><span class="s2"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></span><span class="s6">PokeySquare</span><span class="s2">.audc(4, 8),<span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></span>//convert tone, vol pair to an audc</p>
<p class="p8"><span class="s2"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>audctl: </span><span class="s6">PokeySquare</span><span class="s2">.audctl(0)<span class="Apple-tab-span">	</span></span>//convert ctrl to an audctl</p>
<p class="p5"><span class="Apple-tab-span">	</span>)</p>
<p class="p5">}.play)</p>
<p class="p4"><br></p>
</body>
</html>
